home *** CD-ROM | disk | FTP | other *** search
/ Champak 138 / Volume 138 Aug 19 2011 - Damaged.iso / Games / shadez.swf / scripts / Local / Game / HUD / CHUDPanelUnit.as < prev    next >
Encoding:
Text File  |  2011-08-19  |  10.5 KB  |  320 lines

  1.  
  2. {
  3.    if(true)
  4.    {
  5.       CHUDPanelUnit = ┬º┬ºnewclass(CHUDPanelUnit,Object);
  6.    }
  7. }
  8.  
  9. package Local.Game.HUD
  10. {
  11.    import Local.*;
  12.    import Local.Audio.*;
  13.    import Local.Game.*;
  14.    import Local.Game.Level.*;
  15.    import Local.Game.Thing.*;
  16.    import Local.Game.World.*;
  17.    import Local.Game.World.Map.*;
  18.    import Local.Game.World.Map.Cell.*;
  19.    import STC9.IO.*;
  20.    import STC9.System.*;
  21.    import flash.display.*;
  22.    import flash.events.*;
  23.    import flash.filters.*;
  24.    import flash.geom.*;
  25.    import flash.text.*;
  26.    
  27.    public class CHUDPanelUnit
  28.    {
  29.       
  30.       private static const mMaxSpeed:Number;
  31.       
  32.       private static const zPoint:Point;
  33.       
  34.       private static const mMaxArmor:Number = 300;
  35.       
  36.       {
  37.          if(true)
  38.          {
  39.             zPoint = new Point();
  40.             if(true)
  41.             {
  42.                mMaxSpeed = 30 * CThingSprite.mSpriteScalar;
  43.             }
  44.             mMaxArmor = 300;
  45.          }
  46.       }
  47.       
  48.       private var mHUD:CHUD;
  49.       
  50.       private var mcPanel:MovieClip;
  51.       
  52.       private var mButtons:Object;
  53.       
  54.       private var mSelectedThing:*;
  55.       
  56.       private var mcVisual:MovieClip;
  57.       
  58.       public function CHUDPanelUnit(param1:CHUD)
  59.       {
  60.          super();
  61.          mHUD = param1;
  62.          mcVisual = new Panel_Unit_VIS();
  63.       }
  64.       
  65.       public function AddButton(param1:String, param2:MovieClip, param3:MovieClip, param4:Boolean = true) : void
  66.       {
  67.          param3.mcButton = param2;
  68.          param3.mCommand = param1;
  69.          if(mSelectedThing.mDead)
  70.          {
  71.             ┬º┬ºpush(false);
  72.             if(true)
  73.             {
  74.                param4 = ┬º┬ºpop();
  75.                addr22:
  76.                param3.mEnabled = param4;
  77.                ┬º┬ºpush(param4);
  78.             }
  79.             if(┬º┬ºpop())
  80.             {
  81.                param3.alpha = 1;
  82.                AddMouseEvents(param3);
  83.                SetButtonVisual(param3,"mcOUT");
  84.             }
  85.             else
  86.             {
  87.                param3.alpha = 0.5;
  88.                RemoveMouseEvents(param3);
  89.                SetButtonVisual(param3,"mcDISABLED");
  90.             }
  91.             param3.enabled = param4;
  92.             param2.enabled = false;
  93.             mButtons[param1] = param3;
  94.             return;
  95.          }
  96.          ┬º┬ºgoto(addr22);
  97.       }
  98.       
  99.       public function InitDraw(param1:CHUDPanel) : void
  100.       {
  101.          if(true)
  102.          {
  103.             param1.mDrawInit = true;
  104.             if(true)
  105.             {
  106.                mcPanel = param1.mcPanel;
  107.                if(true)
  108.                {
  109.                   mSelectedThing = mHUD.mThingSelected;
  110.                   if(true)
  111.                   {
  112.                      mcPanel.tbName.text = mSelectedThing.mLongName;
  113.                      if(true)
  114.                      {
  115.                         mcPanel.tbText.text = mSelectedThing.mShortDesc;
  116.                         mcPanel.mcIcon.gotoAndStop(mSelectedThing.mIconIndex);
  117.                      }
  118.                      mcPanel.mcDeceased.visible = false;
  119.                   }
  120.                   SetupButtons();
  121.                }
  122.                mcPanel.mcBar_Speed.gotoAndStop(Math.round(mSelectedThing.mMaxSpeed * mcPanel.mcBar_Speed.totalFrames / mMaxSpeed) + 1);
  123.             }
  124.             mcPanel.mcBar_Armor.gotoAndStop(Math.round(mSelectedThing.mMaxLife * mcPanel.mcBar_Armor.totalFrames / mMaxArmor) + 1);
  125.          }
  126.       }
  127.       
  128.       private function RemoveMouseEvents(param1:MovieClip) : *
  129.       {
  130.          if(param1.hasEventListener(MouseEvent.MOUSE_OVER))
  131.          {
  132.             param1.removeEventListener(MouseEvent.MOUSE_OVER,e_MOUSE_OVER);
  133.          }
  134.          if(param1.hasEventListener(MouseEvent.MOUSE_OUT))
  135.          {
  136.             param1.removeEventListener(MouseEvent.MOUSE_OUT,e_MOUSE_OUT);
  137.          }
  138.          if(param1.hasEventListener(MouseEvent.MOUSE_DOWN))
  139.          {
  140.             param1.removeEventListener(MouseEvent.MOUSE_DOWN,e_MOUSE_DOWN);
  141.          }
  142.          if(param1.hasEventListener(MouseEvent.MOUSE_UP))
  143.          {
  144.             param1.removeEventListener(MouseEvent.MOUSE_UP,e_MOUSE_UP);
  145.          }
  146.          param1.buttonMode = false;
  147.          param1.useHandCursor = false;
  148.       }
  149.       
  150.       private function AddMouseEvents(param1:MovieClip) : *
  151.       {
  152.          param1.addEventListener(MouseEvent.MOUSE_OVER,e_MOUSE_OVER);
  153.          param1.addEventListener(MouseEvent.MOUSE_OUT,e_MOUSE_OUT);
  154.          param1.addEventListener(MouseEvent.MOUSE_DOWN,e_MOUSE_DOWN);
  155.          param1.addEventListener(MouseEvent.MOUSE_UP,e_MOUSE_UP);
  156.          param1.buttonMode = true;
  157.          param1.useHandCursor = true;
  158.       }
  159.       
  160.       public function e_DRAW(param1:Event = null) : void
  161.       {
  162.          var _loc2_:CHUDPanel = null;
  163.          if(true)
  164.          {
  165.             CProfiler.StartProfile("PanelUnit.Draw");
  166.             if(true)
  167.             {
  168.                if(mHUD.mThingSelected)
  169.                {
  170.                   addr23:
  171.                   _loc2_ = CHUDPanel(param1.currentTarget);
  172.                   if(true)
  173.                   {
  174.                      ┬º┬ºpush(_loc2_.mDrawInit);
  175.                      if(true)
  176.                      {
  177.                         if(!┬º┬ºpop())
  178.                         {
  179.                            if(true)
  180.                            {
  181.                               InitDraw(_loc2_);
  182.                               if(true)
  183.                               {
  184.                                  addr51:
  185.                                  mcPanel.mcBar_Health.gotoAndStop(Math.max(1,Math.round(mSelectedThing.mLife * mcPanel.mcBar_Health.totalFrames / mSelectedThing.mMaxLife) + 1));
  186.                                  if(true)
  187.                                  {
  188.                                     ┬º┬ºpush(Boolean(mSelectedThing.mDead));
  189.                                     if(true)
  190.                                     {
  191.                                        if(┬º┬ºpop())
  192.                                        {
  193.                                        }
  194.                                        addr83:
  195.                                        if(┬º┬ºpop())
  196.                                        {
  197.                                           mHUD.DeselectAll(true,true);
  198.                                           addr95:
  199.                                           CProfiler.StopProfile("PanelUnit.Draw");
  200.                                           return;
  201.                                           addr84:
  202.                                        }
  203.                                        ┬º┬ºgoto(addr95);
  204.                                     }
  205.                                     ┬º┬ºpop();
  206.                                  }
  207.                                  ┬º┬ºgoto(addr83);
  208.                                  ┬º┬ºpush(Boolean(mSelectedThing.mDisposed));
  209.                               }
  210.                               ┬º┬ºgoto(addr84);
  211.                            }
  212.                            ┬º┬ºgoto(addr95);
  213.                         }
  214.                         ┬º┬ºgoto(addr51);
  215.                      }
  216.                      ┬º┬ºgoto(addr83);
  217.                   }
  218.                   ┬º┬ºgoto(addr95);
  219.                }
  220.             }
  221.             return;
  222.          }
  223.          ┬º┬ºgoto(addr23);
  224.       }
  225.       
  226.       public function e_MOUSE_OUT(param1:MouseEvent = null) : void
  227.       {
  228.          SetButtonVisual(MovieClip(param1.currentTarget),"mcOUT");
  229.       }
  230.       
  231.       public function SetupButtons() : void
  232.       {
  233.          if(true)
  234.          {
  235.             mButtons = new Object();
  236.             if(true)
  237.             {
  238.                AddButton("proceed",mcPanel.mcIcon_Proceed,mcPanel.mcIcon_Proceed_BG,mSelectedThing.mCommandProceed);
  239.                if(true)
  240.                {
  241.                   AddButton("halt",mcPanel.mcIcon_Halt,mcPanel.mcIcon_Halt_BG,mSelectedThing.mCommandHalt);
  242.                   if(true)
  243.                   {
  244.                      AddButton("takecontrol",mcPanel.mcIcon_TakeControl,mcPanel.mcIcon_TakeControl_BG,mSelectedThing.mCommandTakeControl);
  245.                      if(true)
  246.                      {
  247.                         AddButton("drop",mcPanel.mcIcon_Drop,mcPanel.mcIcon_Drop_BG,mSelectedThing.mCommandDrop);
  248.                         new CHUDTooltip(mHUD,mcPanel.mcIcon_Proceed_BG,"Proceed: commands the unit to move to towards the objective (right-hand side of the map).");
  249.                      }
  250.                      new CHUDTooltip(mHUD,mcPanel.mcIcon_Halt,"Stand ground: commands the unit to stop and just hold this position.");
  251.                   }
  252.                   new CHUDTooltip(mHUD,mcPanel.mcIcon_TakeControl,"Take control: Not implemented in this version.");
  253.                }
  254.                new CHUDTooltip(mHUD,mcPanel.mcIcon_Drop,"Drop load: commands the unit to stop and drop it\'s load, either troops or tank.");
  255.             }
  256.             SelectButton(mButtons[mSelectedThing.mCommand]);
  257.          }
  258.       }
  259.       
  260.       private function SelectButton(param1:MovieClip) : *
  261.       {
  262.          var _loc2_:MovieClip = null;
  263.          for each(_loc2_ in mButtons)
  264.          {
  265.             if(true)
  266.             {
  267.                if(_loc2_ != param1)
  268.                {
  269.                   DeselectButton(_loc2_);
  270.                }
  271.             }
  272.          }
  273.          if(true)
  274.          {
  275.             SetButtonVisual(param1,"mcSELECTED");
  276.             if(true)
  277.             {
  278.                RemoveMouseEvents(param1);
  279.             }
  280.             mSelectedThing.mCommand = param1.mCommand;
  281.          }
  282.       }
  283.       
  284.       public function e_MOUSE_UP(param1:MouseEvent = null) : void
  285.       {
  286.          CAudio.PlayGlobalSound(Click);
  287.          SelectButton(MovieClip(param1.currentTarget));
  288.       }
  289.       
  290.       private function SetButtonVisual(param1:MovieClip, param2:String) : void
  291.       {
  292.          param1.mcButton.transform.colorTransform = mcVisual[param2].transform.colorTransform;
  293.          param1.mcButton.filters = mcVisual[param2].filters;
  294.       }
  295.       
  296.       public function e_MOUSE_DOWN(param1:MouseEvent = null) : void
  297.       {
  298.          SetButtonVisual(MovieClip(param1.currentTarget),"mcDOWN");
  299.       }
  300.       
  301.       public function e_MOUSE_OVER(param1:MouseEvent = null) : void
  302.       {
  303.          if(true)
  304.          {
  305.             SetButtonVisual(MovieClip(param1.currentTarget),"mcOVER");
  306.          }
  307.       }
  308.       
  309.       private function DeselectButton(param1:MovieClip) : *
  310.       {
  311.          if(!param1.mEnabled)
  312.          {
  313.             return;
  314.          }
  315.          AddMouseEvents(param1);
  316.          SetButtonVisual(param1,"mcOUT");
  317.       }
  318.    }
  319. }
  320.